package com.dubbo.homework;

import com.dubbo.ConsumerConfiguration;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class DubboConsumer {



    public static void main(String[] args) throws InterruptedException {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
        context.start();
        ComponentService bean = context.getBean(ComponentService.class);

        while(true){
            executorService.submit(()->bean.setHelloServiceA("Apple"));
            executorService.submit(()->bean.setHelloServiceB("Banana"));
            executorService.submit(()->bean.setHelloServiceC("Cat"));
            TimeUnit.MILLISECONDS.sleep(20);
        }

    }
}
